package com.aaa.vue.controller;

import com.aaa.vue.entity.TabProduct;
import com.aaa.vue.service.productservice;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/product")
public class productcontroller {
    @Autowired
    private productservice productservice;
    @RequestMapping("/selectAll2")
    public String selectAll2(){
        return "productList";
    }
    @ResponseBody
    @RequestMapping("selectAll")
    public List<TabProduct> selectAll(){
        return productservice.selectAll();
    }


    @RequestMapping("/selectbyid1")
    public String selectbyid1(Integer productid, Model model){
        model.addAttribute("productid",productid);
        return "update";
    }
    @ResponseBody
    @RequestMapping("/selectbyid")
    public TabProduct selectbyid(Integer productid){
        return productservice.selectbyid(productid);
    }
    @ResponseBody
    @RequestMapping("/updateProduct")
    public int updateProduct(@RequestBody TabProduct tabProduct){
        return productservice.updateProduct(tabProduct);
    }
}
